package com.cx.mall.user.controller;

import com.cx.mall.common.utils.ResponseVO;
import com.cx.mall.common.model.user.UserInfo;
import com.cx.mall.user.service.IUserInfoService;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 后台用户表 前端控制器
 * </p>
 *
 * @author lyt
 * @since 2025-07-08
 */
@RestController
@RequestMapping("/user")
public class UserInfoController {
    @Autowired
    private IUserInfoService userService;
    @PostMapping("/register")
    public ResponseVO register(@RequestBody UserInfo userInfo){
        // 密码加密
        String hashpw = BCrypt.hashpw(userInfo.getPassword(),BCrypt.gensalt());
        userInfo.setPassword(hashpw);
        // 保存到数据表
        userService.save(userInfo);
        return ResponseVO.success();
    }
}
